package com.tunan.common.resultSub;

import java.util.ArrayList;
import java.util.List;

import com.github.pagehelper.PageInfo;
import com.tunan.common.Result;

public class ResultWithPage<T> extends Result {

	private String ack_code = "SUCCESS";
	private String total;
	private Page_info_inner page_info;
	private List<T> rows = new ArrayList<T>();

	public ResultWithPage(List<T> datas) {
		PageInfo pageInfo = new PageInfo<T>(datas);
		this.page_info = new Page_info_inner(pageInfo);
		this.total = String.valueOf(pageInfo.getTotal());
		this.rows.addAll(datas);
	}

	private class Page_info_inner {
		private long count;
		private int page_num;
		private int page_size;

		public Page_info_inner(PageInfo pageInfo) {
			this.count = pageInfo.getTotal();
			this.page_num = pageInfo.getPageNum();
			this.page_size = pageInfo.getPages();
		}

		public long getCount() {
			return count;
		}

		public int getPage_num() {
			return page_num;
		}

		public int getPage_size() {
			return page_size;
		}

	}

	public String getTotal() {
		return total;
	}

	public void setTotal(String total) {
		this.total = total;
	}

	public Page_info_inner getPage_info() {
		return page_info;
	}

	public void setPage_info(Page_info_inner page_info) {
		this.page_info = page_info;
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	public String getAck_code() {
		return ack_code;
	}

}
